package control;

import gui.StartView;
import sealedGenerator.MWSDeckWriter;
import sealedGenerator.card.Card;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.List;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

public class ExportPoolListener implements ActionListener {
	
	private final List<Card> cards;
	public ExportPoolListener(List<Card> cards){
		this.cards=cards;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		JFileChooser saveDialog=new JFileChooser();
		int returnVal=saveDialog.showSaveDialog(null);
		if(returnVal==JFileChooser.APPROVE_OPTION){
			File saveFile=saveDialog.getSelectedFile();
			MWSDeckWriter.write(saveFile, cards);
			JOptionPane.showMessageDialog(null, "Sealed Pool saved.");
		}
	}
}
